package com.hexb.smh.utils;

import com.hexb.core.utils.MD5Utils;

/**
 * @author : hexb
 */
public class MD5PasswordHelper {

    final static String SALT = "!%^&#%&";
    private final static String DEFAULT_PASSWORD = "123456";
    private final static MD5PasswordHelper instance = new InnerPasswordHelper().helper;

    public String encryptPassword(String pwd) {
        return MD5Utils.MD5(pwd + SALT);
    }

    public boolean compare(String source, String encrypted) {
        return MD5Utils.MD5(source + SALT).equals(encrypted);
    }

    public String getDefaultPassword() {
        return MD5Utils.MD5(DEFAULT_PASSWORD + SALT);
    }

    public static MD5PasswordHelper getInstance() {
        return instance;
    }

    private static class InnerPasswordHelper {
        final private MD5PasswordHelper helper = new MD5PasswordHelper();
    }
}
